Skip to content

Test the schema warnings through a shared log-capture helper - #878

Merged
oryan-block merged 2 commits into
masterfrom
test/867-log-capture
Oct 18, 2026
Merged

oryan-block merged 2 commits into
masterfrom
test/867-log-capture

Conversation

@oryan-block

Copy link
Copy Markdown
Collaborator

Fixes #867

Checklist

  • Pull requests follows the contribution guide
  • New or modified functionality is covered by tests

Description

We log a WARN for a bunch of schema problems we tolerate, but no test checked any of them. So a warning could disappear or change without anything failing.

UnmappedInputFieldsTest already had a withWarnings { ... } helper from #857 that attaches a logback ListAppender and returns the result along with the logged warnings. It's moved to TestUtils.kt as is, except it now listens on the graphql.kickstart.tools logger instead of the root one, so graphql-java's own warnings don't end up in the list.

The tests that already build these schemas now assert the warnings too:

  • unused types: unused unions are reported by their definition and get the members of their extensions when included
  • repeated enum values, interface fields and union members: repeats and extensions without a type keep building
  • extensions of a different kind than their type: extensions of a different kind than the type are ignored
  • a non-repeatable directive applied again by an extension: directives of extensions follow those of the type and are wired

allowUnimplementedResolvers had no test of its own, so MissingFieldResolverTest gets one for the option's warning and the "Missing resolver for field" one.

The lists are exact, so an extra warning fails the test as well as a missing one.

Test only, no library changes. mvn clean verify passes on JDK 25 and on JDK 11 against graphql-java 25.1.

The other warnings (unused dictionary entries and resolvers, JDK proxies, preferGraphQLResolver, setAccessible failures, the deprecated context ones) weren't in the issue and are still untested, but withWarnings works for those too.

oryan-block and others added 2 commits October 18, 2026 17:42
…capture helper

UnmappedInputFieldsTest's withWarnings moves to TestUtils and listens on the library's loggers instead of the root logger. The tests for unused types, allowUnimplementedResolvers, repeated enum values, interface fields and union members, extensions of a different kind and repeated non-repeatable directives now assert the exact warnings.
@sonarqubecloud

Copy link
Copy Markdown

@oryan-block
oryan-block merged commit 3dcbbb7 into master Oct 18, 2026
7 checks passed
@oryan-block
oryan-block deleted the test/867-log-capture branch October 18, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a log-capture helper so tests can assert on warnings

1 participant